﻿using System;

namespace rpxnow_library.rpxnowapi.responses
{
    public class Auth_info
    {
        /// <summary>
        /// RPX can request profile and registration data from the user using the Simple Registration OpenID extension,
        /// the HCard microformat, and soon via the new Portable Contacts protocol. This information may be used to aid
        /// in new user registration, and profile/contact information syncing.
        /// </summary>
        public class Profile
        {
            /// <summary>
            /// The user's OpenID URL. Use this value to sign the user in to your website. This field is always present.
            /// guaranteed
            /// </summary>
            public string identifier { get; internal set; }

            /// <summary>
            /// A human-readable name of the authentication provider that was used for this authentication. 
            /// For well-known providers, RPX sends values such as "Google", "Facebook", and "MySpace"; "Other"
            /// is sent for other providers. New provider names are added over time.	
            /// guaranteed
            /// </summary>
            public string providerName { get; internal set; }

            /// <summary>
            /// Primary key of the user in your database. Only present if you are using the mapping API.
            /// guaranteed if a mapping exists
            /// </summary>               
            public string primaryKey { get; internal set; }

            /// <summary>
            /// The name of this Contact, suitable for display to end-users.
            /// Available from most providers, with user consent.
            /// </summary>
            public string displayName { get; internal set; }

            /// <summary>
            /// The preferred username of this contact on sites that ask for a username.
            /// Available from most providers, with user consent.
            /// </summary>
            public string preferredUsername { get; internal set; }

            /// <summary>
            /// A dictionary of name parts. See the name field section for details.
            /// Available from most providers, with user consent.
            /// </summary>
            public Name name { get; private set; }

            /// <summary>
            /// The gender of this person. Canonical values are 'male', and 'female', but may be any value.
            /// Available from most providers, with user consent.
            /// </summary>
            public string gender { get; internal set; }

            /// <summary>
            /// Date of birth in YYYY-MM-DD format. Year field may be 0000 if unavailable.
            /// Available from most providers, with user consent.
            /// </summary>
            public string birthday { get; internal set; }

            /// <summary>
            /// The offset from UTC of this Contact's current time zone, as of the time this response was returned. 
            /// The value MUST conform to the offset portion of xs:dateTime, e.g. -08:00. 
            /// Note that this value MAY change over time due to daylight saving time, and is thus meant to signify
            /// only the current value of the user's timezone offset.
            /// Available from most providers, with user consent.
            /// </summary>
            public string utcOffset { get; internal set; }

            /// <summary>
            /// An email address at which the person may be reached.
            /// Available from most providers, with user consent. Not available from Twitter, Facebook, or MySpace.
            /// </summary>
            public string email { get; internal set; }

            /// <summary>
            /// An email address at which the person may be reached.
            /// Available from Google and Yahoo!
            /// </summary>
            public string verifiedEmail { get; internal set; }

            /// <summary>
            /// URL of a webpage relating to this person.
            /// Available from some providers, with user consent.
            /// </summary>
            public string url { get; internal set; }

            /// <summary>
            /// A phone number at which the person may be reached.
            /// Available from some providers, with user consent.
            /// </summary>
            public string phoneNumber { get; internal set; }

            /// <summary>
            /// URL to a photo (GIF/JPG/PNG) of the person.
            /// Available from some providers, with user consent.
            /// </summary>
            public string photo { get; internal set; }

            /// <summary>
            /// See the address field section for details. 
            /// Available from some providers, with user consent.
            /// </summary>
            public Address address { get; private set; }

            public class Name
            {
                /// <summary>
                /// The full name, including all middle names, titles, and suffixes as appropriate, 
                /// formatted for display (e.g. Mr. Joseph Robert Smarr, Esq.). 
                /// This is the Primary Sub-Field for this field, for the purposes of sorting and filtering.
                /// </summary>
                public string formatted { get; internal set; }
                /// <summary>
                /// The family name of this Contact, or "Last Name" in most Western languages 
                /// (e.g. Smarr given the full name Mr. Joseph Robert Smarr, Esq.
                /// </summary>
                public string familyName { get; internal set; }

                /// <summary>
                /// The given name of this Contact, or "First Name" in most Western languages 
                /// (e.g. Joseph given the full name Mr. Joseph Robert Smarr, Esq.).
                /// </summary>
                public string givenName { get; internal set; }
            }

            public class Address
            {
                /// <summary>
                /// The full mailing address, formatted for display or use with a mailing label.
                /// </summary>
                public string formatted { get; internal set; }

                /// <summary>
                /// The full street address component, which may include house number, street name, PO BOX, and multi-line extended street address information.
                /// </summary>
                public string streetAddress { get; internal set; }

                /// <summary>
                /// The city or locality component.
                /// </summary>
                public string locality { get; internal set; }

                /// <summary>
                /// The state or region component.
                /// </summary>
                public string region { get; internal set; }

                /// <summary>
                /// Postal code or zipcode.
                /// </summary>
                public string postalCode { get; internal set; }

                /// <summary>
                /// The country name component.
                /// </summary>
                public string country { get; internal set; }
            }

            public Profile()
            {
                this.name = new Name();
                this.address = new Address();
            }
        }
        public Profile profile { get; private set; }

        public class Err
        {
            public string msg { get; internal set; }
            public int code { get; internal set; }
        }
        public Err err { get; private set; }

        public string stat { get; internal set; }

        public bool hasError { get { return stat != "ok"; } }

        internal Auth_info()
        {
            this.profile = new Profile();
            this.err = new Err();
            this.stat = "fail";
        }
    }
}
